package com.xmy.aboutgeneric;

// 泛型演示
public class GenericDemo<T> {
    T value;

    public GenericDemo(){};

    public GenericDemo(T value) {
        this.value = value;
    }

    public static void main(String[] args) {

        GenericDemo<Integer> genericDemo1 = new GenericDemo<>();
        genericDemo1.setValue(99);

        GenericDemo<String> genericDemo2 = new GenericDemo<>();

        genericDemo2.setValue("apple");

        System.out.println("the " + genericDemo2.getValue() + " is " + genericDemo1.getValue() + " yuan.");

    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }
}
